
package models.spider.policy;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 
 * @author laurent@opprecht.info
 */
public class Or extends Policy {

    static Policy create(final List<IPolicy> policies) {
        return new And(policies);
    }

    protected List<IPolicy> policies = new ArrayList<IPolicy>();

    public Or(final List<IPolicy> policies) {
        this.policies = policies;
    }

    public Or(final IPolicy... policies) {
        this.policies = Arrays.asList(policies);
    }

    List<IPolicy> getPolicies() {
        return this.policies;
    }

    @Override
    public boolean accept(final String url) {
        for (IPolicy policy : policies) {
            if (policy.accept(url)) {
                return true;
            }
        }
        return false;
    }
}